<?php
$cs = Yii::app()->getClientScript();
$cs->registerCSSFile(Yii::app()->request->baseUrl . '/css/mobile/booking_find_1.css');
?>
<?php
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
$wxControl = $screen->getChildControl('BUIWXControl_1');
$cart = new BWCart();
$view = $cart->getView(array('itemData' => array('paymentStatus' => bcart::Payment_Status_Paid)));
?>                      

<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<header class="navbar">
                <div class="nav-wrap-left">
<!--                    <a class="react back" href="#"><i class="text-icon icon-back"></i></a>-->
                </div>
            <h1 class="nav-header">我的已支付订单</h1>

        <?php
        $wxControl->renderView('booking_navigation', array());
        ?>
        </header>
<style>
    .newInput{
        position: absolute;
width: 20px;
height: 20px;
margin-left: 20px;
    }
    .newCancel{
        height: .94rem;line-height: .94rem;  font-size: .4rem;
    }
    .newSee{
        width: 2.4rem;
    }
    .newDel{
        margin-top: 10px;
margin-right: 5px;
    }
</style>
<div id="tips"></div>
<div>
    <dl class="list" id="orders">
	<dd>
	<dl>
        <?php
        $totalMoney = 0;
        $serial = 0;
        $bookingTable = new BTreeTable('BWInputValue');
        foreach ($view as $cartList) {
            if ($cartList instanceof BTreeList) {
                $serial++;
                $cartId = $cartList->getId();
                $price = $cartList->getItem('price')->value;
                $unit = $cartList->getItem('moneyUnit')->value;
                $quantity = $cartList->getItem('quantity')->value;
                $productName = $cartList->getItem('productName')->value;
                $productId = $cartList->getItem('productId')->value;
                $bookingItem = new BWInputValue($productId);
                $bookingList = new BTreeList($bookingItem);
                if ($bookingList instanceof BTreeList){
                    $courtDisplayName = $bookingList->getItem('courtDisplayName')->value;
                    $date = date('Y.n.j', $bookingList->getItem('startTime')->value);
                    $startTime = date('G:i', $bookingList->getItem('startTime')->value);
                    $endTime = date('G:i', $bookingList->getItem('endTime')->value);
                    $court_price =  $bookingList->getItem('price')->value;
                    $region = $bookingList->getItem('region')->value;
                    $str = $bookingList->getItem('courtName')->value;
                    $str = trim($str);
                    if (!empty($str)) {
                        $result = '';
                        for ($i = 0; $i < strlen($str); $i++) {
                            if (is_numeric($str[$i])) {
                                $result.=$str[$i];
                            }
                        }
                    }
                    $bookdetail = new BWMessage($result);
                    $courtMedia = $bookdetail->getMediaManager()->getMedia('image');
                    $courtImage = " <h4>No Picture!</h4>";
                    if ($courtMedia instanceof BWMedia) {
                        $courtImage = $bookdetail->getMediaManager()->getMedia('image')->getContent();
                    }
                }
                $paidMoney = $price * $quantity;
                $paidTime = $cartList->getItem('paidTime')->value;
                $paidTimeString = date('Y.m.d G:i:s', $paidTime);
            }
            ?>
		<dd class="dealcard dd-padding">
                    <div class="dealcard-block-right" style="margin-left: 0px;height: auto;">
<!--                        <div class="dealcard-brand single-line">
                          <?php // echo $productName; ?>
                        </div>
                        <small>总价：<?php // echo $paidMoney; ?> 元&nbsp;&nbsp; </small>-->
                        <div class="right_content" style="float: left;padding-left: .1rem;/* padding-top: .2rem; */">
                            <span style="color:black;"><?php echo $courtDisplayName; ?></span>
                            <div>
                                <span class="stars" style="margin-top:.25rem;">
                                    <i class="text-icon" style="font-family: inherit;font-weight: bold;"><span class="booking_date"><?php echo $date; ?></span>&nbsp;<?php echo $startTime; ?>-<?php echo $endTime; ?><?php // echo $regionAlias;?></i>
                            </span>
                            </div>
                            <div class="price" style="margin-top:.2rem;">
                                <strong style="color:#2BB2A3;font-size: .5rem;"><?php echo $court_price;?></strong>
                                <span>元</span>
                            </div>
                        </div>
                        <div class="right_btn" style="position:absolute;right: .1rem;top: .8rem;">
                            <span class="line-right">
                         <?php
                        $bookingRow = $bookingTable->getListById($productId);
                        $cancelTime = $bookingRow->getItem('bookingCancelTime')->value;
                        ?>   
                        <?php 
                               echo $wxControl->getLink(array('name' => '订单详情', 'id' => 'showBookingDetail_1'), array(
                               'cartId' => $cartId, 'bookingId' => $productId,'state'=>'paid',
                               'ajaxContainerId' => 'myModal2',
                               'htmlOptions' => array(
                                   'enctype' => 'multipart/form-data',
                                   'class'=>'btn btn-weak color-strong newDel',
                               ),
                               'ajaxOptions' => array(
                                   'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal2").modal("show");}')
                           ));
                           ?>
                    <?php 
                        if ($cancelTime > time()) {
                        echo $wxControl->getLink(array('name' => '取消预订', 'id' => 'cancelPaidBooking_1'), array(
                        'cartId' => $cartId, 'bookingId' => $productId,'result'=>'cancel',
                        'htmlOptions' => array(
                        'class'=>'btn btn-weak color-strong newDel',
                        )
                        ));
                        }
                        else
                        {
                            echo '<a class="btn btn-weak color-strong newDel">不可取消</a>';
                        }
                        ?>    
                               </span>
                        </div>
                        <div style="width: 100%;height: .01rem;clear: both;margin-bottom: .2rem;"></div>
                        <small>交易时间：<?php echo $paidTimeString; ?></small><br/>
    

		   </div>   
                </dd>
 <?php } ?>
                

                
    </dl></dd>
    </dl>
	
</div>
<footer>
        <div class="footer-copyright">
            <div class="hr"></div>
            <span class="footer-copyright-text">
			Copyright © 2014 billyn.net </span>
        </div>
    </footer>                        